import urllib.request
import urllib.parse
import ssl

ssl._create_default_https_context = ssl._create_unverified_context
url = 'https://movie.douban.com/j/chart/top_list?type=24&interval_id=100%3A90&action=&start=0&limit=20'

# 是get请求
headers = {
    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36",
}

request = urllib.request.Request(url=url, headers=headers)

responest = urllib.request.urlopen(request)

content = responest.read().decode('utf-8')

f = open('douban.json', 'w', encoding='UTF-8')
f.write(content)
f.close()

print(content)